package com.gdepri.mqtt.publisher;

import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;

//@Component
public class PublishSampleV1 {

//    @Autowired
    MqttPublisher mqttPublisher;


    @PostConstruct
    public void init()
    {
        System.out.println("PublishSampleV1已经初始化");
//        System.out.println("PublishSampleV1被注入");
//        System.out.println(mqttPublisher);
//        mqttPublisher.send(
//                "test11",
//                "are you 很好？",
//                "/v1/devices/yibuisbest/topo/test");
    }

    public void send(){
                mqttPublisher.send(
                "test11",
                "are you 很好？",
                "/v1/devices/yibuisbest/topo/test");
    }

}
